home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / AmigaTalk / user / DataBase.st < prev    next >
Text File  |  2004-01-31  |  45KB  |  1,478 lines

  1. " -------------------------------------------------------------------------- "
  2. " DataBase Class is an interface to the dBC III Library of functions         " 
  3. " written by Lattice Inc. for the Amiga.                                     "
  4. " Issue ')i AmigaTalk:User/DataBase.st' from the Single Command Line String  "
  5. " gadget in order to include these Classes into the AmigaTalk environment.   "
  6. ""
  7. " Be sure to read (& hopefully understand) the Test files associated with    "
  8. " these Classes!                                                             "
  9. " -------------------------------------------------------------------------- "
  10.  
  11. Class DataBase :Object 
  12. !
  13.   private      private2           memoPresent    myTemplate   
  14.   recordSize   myCurrentRecordNum howManyRecords currentRecStatus 
  15.   numFields    myCurrentKey       myFileName
  16. !
  17. [
  18.    lastErrorNumber
  19.      ^ <primitive 209 9 3>
  20. |
  21.    numberOfRecords ! chk !
  22.  
  23.      chk <- <primitive 209 6 8 private>.
  24.      
  25.      (chk < 0)
  26.         ifTrue: [ self printError: (self lastErrorNumber).
  27.                   ^ nil ].
  28.         
  29.      ^ howManyRecords <- chk
  30. |
  31.    recordSize
  32.      ^ recordSize
  33. |
  34.    numberOfFields
  35.      ^ numFields
  36. |
  37.    currentRecordNumber
  38.      ^ currentRecordNum
  39. |
  40.    printError: errNum ! dbErrs !
  41.      dbErrs <- DBErrs new.
  42.  
  43.      (dbErrs errString: errNum) print.
  44.      
  45.      ^ nil
  46. |
  47.    failCheck: check with: failTest for: methodName
  48.      (failTest)
  49.        ifTrue: [ (methodName, ' method FAILED because:') print.
  50.  
  51.                  ^ self printError: check ].
  52.  
  53.      ^ nil
  54. |
  55.    xxxCloseMemoFile ! chk !                           " dBmclose() "
  56.      chk <- <primitive 209 7 0 private2>.
  57.  
  58.      self failCheck: chk with: (chk ~= 0) for: 'xxxCloseMemoFile'
  59. |
  60.    xxxOpenMemoFile: memoFileName                      " dBmopen() "
  61.  
  62.      private2 <- <primitive 209 7 2 memoFileName>.
  63.  
  64.      (private2 isNil) 
  65.        ifTrue: [ (memoFileName, ' FAILED to open!' ) print ]
  66.      
  67.      ^ private2
  68. |
  69.    xxxCreateMemoFile: memoFileName ! chk !            " dBmcreat() "
  70.      chk <- <primitive 209 7 1 memoFileName>.
  71.  
  72.      self failCheck: chk with: (chk ~= 0) for: 'xxxCreateMemoFile'
  73. |
  74.    cleanup   " NOTE:  This (will be) is a time-consuming operation! "
  75.      ^ nil
  76. |
  77.    restoreInactiveRecord: recordNumber ! chk !
  78.      chk <- <primitive 209 6 9 private recordNumber>.
  79.  
  80.      self failCheck: chk with: (chk ~= 0) for: 'restoreInactiveRecord:'.
  81.      
  82.      (recordNumber = myCurrentRecordNum)
  83.         ifTrue: [ currentRecStatus <- 0 ]
  84. |   
  85.    inactivateRecord: recordNumber ! chk !
  86.      chk <- <primitive 209 6 11 private recordNumber>.
  87.  
  88.      self failCheck: chk with: (chk ~= 0) for: 'inactivateRecord:'.
  89.      
  90.      (recordNumber = myCurrentRecordNum)
  91.         ifTrue: [ currentRecStatus <- 1 ]
  92. |
  93.    currentRecordStatus
  94.      (currentRecStatus = 0)
  95.        ifTrue:  [ ^ 'Active'   ]
  96.        ifFalse: [ ^ 'Inactive' ] " (marked for deletion by '*' in DBaseIII) "
  97. |
  98.    getFileInformation ! chk !
  99.      chk <- <primitive 209 6 4 private (self template)>.
  100.  
  101.      (chk isNil)
  102.        ifTrue: [ self printError: (self lastErrorNumber) ].
  103.        
  104.      ^ chk
  105. |
  106.    create: fileName for: recordTemplate ! chk dbFileName dbMemoName numFields !
  107.  
  108.      " TESTED & WORKING! "
  109.  
  110.      currentRecStatus   <- 0.
  111.      howManyRecords     <- 0.
  112.      myCurrentRecordNum <- 0.
  113.      memoPresent        <- false.
  114.      dbFileName         <- (fileName, '.DBF').
  115.      myFileName         <- dbFileName.
  116.      numFields          <- recordTemplate numberOfFields.
  117.      recordSize         <- recordTemplate recordSize.
  118.      myCurrentKey       <- nil.
  119.        
  120.      chk <- <primitive 209 6 1 dbFileName numFields recordTemplate>.
  121.      
  122.      (chk isNil)
  123.         ifTrue: [ ^ nil ].
  124.  
  125.      private <- chk.
  126.       
  127.      " Check recordTemplate to see if there are any memo fields present "
  128.  
  129.      (<primitive 209 6 0 recordTemplate> = true)
  130.         ifTrue: [ dbMemoName <- (fileName, '.DBT').
  131.  
  132.                   memoPresent <- true.
  133.                     
  134.                   self xxxCreateMemoFile: dbMemoName.
  135.                 ].
  136.      
  137.      self xxxTemplate: recordTemplate.
  138.      
  139.      ^ private
  140. |
  141.    xxxTemplate: useThisTemplate
  142.      myTemplate <- useThisTemplate
  143. |
  144.    template
  145.      ^ myTemplate
  146. |
  147.    readTemplateFrom: fileName ! chk !
  148.      " Open a .DBF file & read in the Record Field descriptors.
  149.      * Create an instance of DBRecordTemplate & return it if all 
  150.      * is okay, otherwise return nil.  The file is closed after 
  151.      * we are done.  This method is only for existing DataBases!
  152.      "
  153.      chk <- <primitive 209 6 13 fileName 'DBRecordTemplate' >.
  154.      
  155.      (chk isNil)
  156.         ifTrue: [ self printError: (self lastErrorNumber).
  157.                   ^ nil ].
  158.                   
  159.      self xxxTemplate: chk.
  160.      
  161.      ^ chk
  162. |
  163.    open: fileName
  164.      " So, you already filled myTemplate with readTemplateFrom:, right? "
  165.  
  166.      ^ self open: fileName for: (self template) 
  167. |
  168.    open: fileName for: recordTemplate  ! chk dbFileName dbMemoName !   
  169.  
  170.      " TESTED & WORKING! "
  171.  
  172.      currentRecStatus <- 0.
  173.      dbFileName       <- (fileName, '.DBF').
  174.  
  175.      ((self template) isNil)
  176.         ifTrue: [ self create: fileName for: recordTemplate ].
  177.              
  178.      chk <- <primitive 209 6 2 dbFileName>.
  179.      
  180.      (chk isNil)
  181.        ifTrue: [ self printError: (self lastErrorNumber).
  182.                  ^ nil ].
  183.      
  184.      private     <- chk.  
  185.      memoPresent <- false.
  186.  
  187.      ((self template) notNil)
  188.         ifTrue: [ memoPresent <- <primitive 209 6 0 (self template)>.
  189.  
  190.                   (memoPresent)
  191.  
  192.                   ifTrue: [ dbMemoName <- (fileName, '.DBT').
  193.                    
  194.                             chk <- self xxxOpenMemoFile: dbMemoName.
  195.                    
  196.                             (chk isNil)
  197.                              ifTrue: [ self printError: (self lastErrorNumber).
  198.                                        <primitive 209 6 3 private>.
  199.                                        ^ chk ]. 
  200.                               
  201.                             private2 <- chk.
  202.                           ]
  203.                 ].
  204.  
  205.      self numberOfRecords.
  206.  
  207.      myCurrentRecordNum <- 1.
  208.      myFileName         <- dbFileName.
  209.      numFields          <- recordTemplate numberOfFields.
  210.      recordSize         <- recordTemplate recordSize.
  211.      myCurrentKey       <- nil.
  212.  
  213.      self xxxTemplate: recordTemplate.
  214.      
  215.      ^ private
  216. |
  217.    close ! chk !
  218.  
  219.      " TESTED & WORKING! "
  220.  
  221.      chk <- <primitive 209 6 3 private>.
  222.      
  223.      self failCheck: chk with: (chk ~= 0) for: 'close'.
  224.       
  225.      (memoPresent)
  226.         ifTrue: [ self xxxCloseMemoFile ]
  227. |
  228.    write: recordData as: recordNumber ! chk aMemo !
  229.  
  230.      " TESTED & WORKING! "
  231.  
  232.      (memoPresent = true)
  233.         ifTrue: [ (1 to: (myTemplate numberOfFields)) 
  234.                      do: [ :m | aMemo <- myTemplate fieldAt: m.
  235.  
  236.                           (aMemo fieldType = $M)
  237.                             ifTrue: [ aMemo putMemo: (aMemo memoContents)
  238.                                                into: private2.
  239.  
  240.                                       myTemplate at: m put: aMemo. 
  241.                                     ]
  242.                          ]
  243.                 ].
  244.                                       
  245.      chk <- <primitive 209 6 5 private recordNumber recordData self>.
  246.  
  247.      self failCheck: chk with: (chk ~= 0) for: 'write:as:'.    
  248.  
  249.      myCurrentRecordNum <- recordNumber.
  250.      
  251.      self numberOfRecords.
  252.      
  253.      ^ self updateFile
  254. |
  255.    read: recordNumber into: recordData ! chk memoPriv memoData !
  256.  
  257.      " TESTED & WORKING! "
  258.  
  259.      chk <- <primitive 209 6 6 private recordNumber recordData currentRecStatus>.
  260.  
  261.      self failCheck: chk with: (chk ~= 0) for: 'read:into:'.
  262.  
  263.      (memoPresent = true)
  264.         ifTrue: [ " Need to read in a Memo field(s) also: "
  265.  
  266.                   (1 to: (myTemplate numberOfFields))
  267.                    do: [ :m | 
  268.  
  269.                         memoPriv <- myTemplate fieldAt: m.
  270.   
  271.                         (memoPriv fieldType = $M)
  272.                          ifTrue: [ memoData <- memoPriv getMemoFrom: private2.
  273.                                        
  274.                                    memoPriv memoContents: memoData. ]
  275.                        ].
  276.                 ].
  277.  
  278.      myCurrentRecordNum <- recordNumber.
  279. |
  280.    updateFile ! chk !
  281.      chk <- <primitive 209 6 7 private>.
  282.  
  283.      ^ self failCheck: chk with: (chk ~= 0) for: 'updateFile'.    
  284. |
  285.    add: keyString to: keyFileObject for: recordNumber ! chk ! " dBakey() "
  286.  
  287.      chk <- <primitive 209 8 11 keyFileObject keyString recordNumber>.
  288.  
  289.      myCurrentKey <- keyString.
  290.      
  291.      self failCheck: chk with: (chk ~= 0) for: 'addKey:to:for:'.
  292. |
  293.    putRecordTo: recordData using: keyString from: keyFileObject 
  294.      ! chk ! " dBputrk() "
  295.    
  296.      " recData is a DBData Object "
  297.      chk <- <primitive 209 8 15 keyFileObject private keyString recordData>.
  298.  
  299.      myCurrentKey <- keyString.
  300.  
  301.      self failCheck: chk with: (chk ~= 0) for: 'putRecordTo:using:from:'.    
  302. |
  303.    getRecordBy: keyString from: keyFileObject for: recordData 
  304.      ! chk ! " dBgetrk() "
  305.  
  306.      " TESTED & WORKING! "
  307.  
  308.      " recordData is a DBData Object big enough to hold a record for the
  309.      * DataBase & keyString is an ordinary String that contains the 
  310.      * value(s) necessary to satisfy the key Expression required for the
  311.      * given keyFileObject
  312.      "
  313.      chk <- <primitive 209 8 14 keyFileObject private keyString 
  314.                                 recordData    currentRecStatus  >.
  315.      
  316.      myCurrentKey <- keyString.
  317.  
  318.      (chk isNil) 
  319.        ifTrue:  [ ('"getRecordBy:from:for:" FAILED!' ) print ].
  320.  
  321.      ^ chk
  322. |
  323.    readNextRecord: keyFileObject into: recordData ! chk ! " dBgetnr() "
  324.  
  325.      " recordData is a DBData Object "
  326.  
  327.      chk <- <primitive 209 8 5 keyFileObject private currentRecStatus recordData>.
  328.      
  329.      (chk isNil) 
  330.        ifTrue:  [ ('"readNextRecord:into:" FAILED!' ) print ].
  331.  
  332.      ^ chk " The recordData "
  333. |
  334.    readPrevRecord: keyFileObject into: recordData ! chk !  " dBgetpr() "
  335.  
  336.      " recordData is a DBData Object "
  337.  
  338.      chk <- <primitive 209 8 6 keyFileObject private currentRecStatus recordData>.
  339.      
  340.      (chk isNil) 
  341.        ifTrue:  [ ('"readPrevRecord:into:" FAILED!' ) print ].
  342.  
  343.      ^ chk " The recordData "
  344. |
  345.    update: recordData number: recNumber ! chk !
  346.      chk <- <primitive 209 6 10 private recNumber recordData>.
  347.      
  348.      self failCheck: chk with: (chk ~= 0) for: 'update:number:'.
  349.      
  350.      myCurrentRecordNum <- recNumber
  351. |
  352.    removeRecord: recordNumber ! chk !
  353.  
  354.      " WARNING:  This is an IRREVERSIBLE operation! (Tested & working)"
  355.  
  356.      chk <- <primitive 209 6 12 private recordNumber>.
  357.      
  358.      self failCheck: chk with: (chk ~= 0) for: 'removeRecord:'
  359. ]
  360.  
  361. " -------------------------------------------------------------------------- "
  362. " NOTE:  size has to be the size of the largest record expected to be in the "
  363. "        DataBase. "
  364. " TESTED & WORKING! "
  365. " -------------------------------------------------------------------------- "
  366.  
  367. Class DBData :String ! theData mySize !
  368. [
  369.    print
  370.      ^ theData print
  371. |   
  372.    new: size
  373.       (size > 0)
  374.          ifTrue: [ theData <- super new: size.
  375.  
  376.                    mySize  <- size.
  377.  
  378.                    ^ self ].
  379.       
  380.       ('size ', size asString, ' improper for DBData Class instance!') print.
  381.  
  382.       ^ nil
  383. |
  384.    reset
  385.       " This method allows us to re-use an instance of this Class: "
  386.       <primitive 209 9 9 theData mySize>
  387. |
  388.    modifyWith: dataString at: offset length: length 
  389.  
  390.       <primitive 209 9 7 theData dataString offset length mySize>.
  391.  
  392.       ^ self
  393. |
  394.    at: index
  395.       ^ theData at: index
  396. |
  397.    retrieveFieldAt: offset length: length
  398.       ^ <primitive 209 9 10 theData offset length>
  399. |
  400.    size
  401.       ^ mySize
  402. ]
  403.  
  404. " -------------------------------------------------------------------------- "
  405. " DBRecordTemplate Class (recordObject) is an Array of DBField Objects.      "
  406. ""
  407. " This class is used to define the various fields that a DataBase will con-  "
  408. " tain & is set up BEFORE you use it to create/open a DataBase.              "
  409. " -------------------------------------------------------------------------- "
  410.  
  411. Class DBRecordTemplate :Object 
  412. ! fieldArray myRecordSize numberFields offsetArray !
  413. [
  414.    recordSize
  415.      ^ myRecordSize
  416. |
  417.    numberOfFields
  418.      ^ numberFields
  419. |
  420.    addField: fieldObject at: index
  421.       fieldArray  at: index put: fieldObject.
  422.       offsetArray at: index put: myRecordSize.
  423.             
  424.       myRecordSize <- myRecordSize + (fieldObject fieldWidth)
  425. |
  426.    fieldAt: index
  427.       ^ fieldArray at: index
  428. |
  429.    offsetAt: index             
  430.       " Simplify bookkeeping.  Now you only have to keep track of
  431.       * the field index!
  432.       "
  433.       ^ offsetArray at: index
  434. |
  435.    new: howManyFields
  436.      
  437.       myRecordSize <- 0.
  438.       
  439.       numberFields <- howManyFields.
  440.  
  441.       fieldArray   <- Array new: howManyFields.
  442.       offsetArray  <- Array new: howManyFields.
  443.  
  444.       ^ self
  445. ]
  446.  
  447. " -------------------------------------------------------------------------- "
  448. " DBField is an Abstract Class.                                              "
  449. " -------------------------------------------------------------------------- "
  450.  
  451. Class DBField :Object
  452. [
  453.    fieldObject
  454.      ^ super subclassResponsibility: 'fieldObject'
  455. |
  456.    fieldName
  457.      ^ super subclassResponsibility: 'fieldName'
  458. |
  459.    fieldType
  460.      ^ super subclassResponsibility: 'fieldType'
  461. |
  462.    fieldWidth
  463.      ^ super subclassResponsibility: 'fieldWidth'
  464. |
  465.    decimalPlaces
  466.      ^ super subclassResponsibility: 'decimalPlaces'
  467. |
  468.    create: fieldName type: typeChar width: w decimalPlaces: d
  469.      ^ super subclassResponsibility: 'create:type:width:decimalPlaces:'
  470. |
  471.    failCheck: check with: failTest for: methodName ! dbErrs error !
  472.      (failTest)
  473.         ifTrue: [ dbErrs <- DBErrs new.
  474.                   error  <- dbErrs errString: check.
  475.  
  476.                   (methodName, ' method FAILED because:') print.
  477.                   error print.
  478.                 ]
  479. ]
  480.  
  481. " -------------------------------------------------------------------------- "
  482. " This Class is only needed for creating new DataBase DBRecordTemplate       "
  483. " String-type Fields.                                                        "
  484. " -------------------------------------------------------------------------- "
  485.  
  486. Class DBFieldString :DBField 
  487. ! private myFieldName private2 myFieldWidth private3 !
  488. [
  489.    fieldObject
  490.      ^ private
  491. |
  492.    fieldName
  493.      ^ myFieldName
  494. |
  495.    fieldType
  496.      ^ $C
  497. |
  498.    fieldWidth
  499.      ^ myFieldWidth
  500. |
  501.    decimalPlaces
  502.      ^ private3
  503. |
  504.    create: fieldName length: w
  505.      ^ self create: fieldName type: $C width: w decimalPlaces: 0
  506. |   
  507.    create: fieldName type: typeChar width: w decimalPlaces: d ! chk !
  508.  
  509.      " The fieldName can only be up to 10 characters 
  510.      * long (DB-III limitation). 
  511.      "
  512.      chk <- <primitive 209 9 0 fieldName typeChar w d>. 
  513.      
  514.      (chk isNil)
  515.         ifTrue:  [ ('create:type:width:decimalPlaces: FAILED!' ) print.
  516.  
  517.                    ^ nil
  518.                  ].
  519.         
  520.      private      <- chk.
  521.      myFieldName  <- fieldName.
  522.      private2     <- typeChar.
  523.      myFieldWidth <- w.
  524.      private3     <- d.
  525.      
  526.      ^ self
  527. ]
  528.  
  529. " -------------------------------------------------------------------------- "
  530. " This Class is only needed for creating new DataBase DBRecordTemplate       "
  531. " Memo-type Fields.                                                          "
  532. " -------------------------------------------------------------------------- "
  533.  
  534. Class DBFieldMemo :DBField 
  535. ! private myFieldName private2 private3 private4 maxSize myMemoContents !
  536. [
  537.    fieldObject
  538.      ^ private
  539. |
  540.    fieldName
  541.      ^ myFieldName
  542. |
  543.    fieldType
  544.      ^ private2
  545. |
  546.    fieldWidth
  547.      ^ private3
  548. |
  549.    decimalPlaces
  550.      ^ private4
  551. |
  552.    memoContents
  553.      ^ myMemoContents
  554. |
  555.    memoContents: newContents
  556.      myMemoContents <- newContents     
  557. |
  558.    createMemo: fieldName ofSize: memoSize
  559.      myMemoContents <- String new: memoSize.
  560.      
  561.      ^ self create: fieldName type: $M width: 10 decimalPlaces: 0
  562. |   
  563.    create: fieldName type: typeChar width: w decimalPlaces: d ! chk !
  564.  
  565.      " The fieldName can only be up to 10 characters 
  566.      * long (DB-III limitation). 
  567.      "
  568.      chk <- <primitive 209 9 0 fieldName typeChar w d>. 
  569.      
  570.      (chk isNil)
  571.         ifTrue:  [ ('create:type:width:decimalPlaces FAILED!' ) print.
  572.  
  573.                    ^ nil
  574.                  ].
  575.         
  576.      private      <- chk.
  577.      myFieldName  <- fieldName.
  578.      private2     <- typeChar.
  579.      private3     <- w.
  580.      private4     <- d.
  581.      
  582.      ^ self
  583. |
  584.    setMaximumMemoSizeTo: maximumSize
  585.       <primitive 209 7 5 maximumSize>.
  586.  
  587.       maxSize <- maximumSize.
  588. |
  589.    maximumMemoSize
  590.       ^ maxSize <- <primitive 209 7 6>    
  591. |
  592.    getMemoFrom: memoFileObj  ! chk ! " dBgetm() "
  593.  
  594.      chk <- <primitive 209 7 3 memoFileObj private myMemoContents>.
  595.       
  596.      super failCheck: chk with: (chk ~= 0) for: 'getMemoFrom:'.
  597.      
  598.      ^ myMemoContents
  599. |
  600.    putMemo: memoString into: memoFileObj   ! chk ! " dBputm() "
  601.      chk <- <primitive 209 7 4 memoFileObj memoString private>.
  602.       
  603.      super failCheck: chk with: (chk ~= 0) for: 'putMemo:into:'
  604. ]
  605.  
  606. " -------------------------------------------------------------------------- "
  607. " This Class is only needed for creating new DataBase DBRecordTemplate       "
  608. " Floating-point-type Fields.                                                "
  609. " -------------------------------------------------------------------------- "
  610.  
  611. Class DBFieldFloat :DBField 
  612. ! private myFieldName myFieldType myFieldWidth myDecPlaces !
  613. [
  614.    fieldObject
  615.      ^ private
  616. |
  617.    fieldName
  618.      ^ myFieldName
  619. |
  620.    fieldType
  621.      ^ myFieldType
  622. |
  623.    fieldWidth
  624.      ^ myFieldWidth
  625. |
  626.    decimalPlaces
  627.      ^ myDecPlaces
  628. |
  629.    ascii: aFloatString toField: fieldString width: w 
  630.                  decimalPlaces: d                      " dBatofld() "
  631.      ! chk !
  632.      
  633.      chk <- <primitive 209 9 4 aFloatString fieldString w d>.
  634.      
  635.      super failCheck: chk with: (chk ~= 0) 
  636.                  for: 'ascii:toField:width:decimalPlaces:'.
  637.      
  638.      ^ fieldString
  639. |
  640.    field: aFieldString toASCII: floatString width: w 
  641.  
  642.      ! chk ! " dBfldtoa() "
  643.  
  644.      chk <- <primitive 209 9 5 aFieldString w floatString>.
  645.      
  646.      super failCheck: chk with: (chk ~= 0) for: 'field:toASCII:width:'.
  647.  
  648.      ^ floatString
  649. |
  650.    create: fieldName type: typeChar width: w decimalPlaces: d ! chk !
  651.  
  652.      " The fieldName can only be up to 10 characters 
  653.      * long! (DB-III limitation)
  654.      *
  655.      * Valid values for typeChar are (Uppercase is preferred):
  656.      *
  657.      *   $N - Numeric field
  658.      "
  659.      chk <- <primitive 209 9 0 fieldName typeChar w d>. 
  660.      
  661.      (chk isNil)
  662.         ifTrue:  [ ('create:type:width:decimalPlaces: FAILED!' ) print.
  663.  
  664.                    ^ nil
  665.                  ].
  666.         
  667.      private       <- chk.
  668.      myFieldName   <- fieldName.
  669.      myFieldType   <- typeChar.
  670.      myFieldWidth  <- w.
  671.      myDecPlaces   <- d.
  672.      
  673.      ^ self
  674. ]
  675.  
  676. " -------------------------------------------------------------------------- "
  677. " This Class is only needed for creating new DataBase DBRecordTemplate       "
  678. " Date-type Fields.                                                          "
  679. " -------------------------------------------------------------------------- "
  680.  
  681. Class DBFieldDate :DBField 
  682. ! private myFieldName myFieldType myFieldWidth myDecPlaces !
  683. [
  684.    fieldObject
  685.      ^ private
  686. |
  687.    fieldName
  688.      ^ myFieldName
  689. |
  690.    fieldType
  691.      ^ myFieldType
  692. |
  693.    fieldWidth
  694.      ^ myFieldWidth
  695. |
  696.    decimalPlaces
  697.      ^ myDecPlaces
  698. |
  699.    ascii: aDateString toField: fieldString width: w " dBatofld() "
  700.      ! chk !
  701.      
  702.      chk <- <primitive 209 9 4 aDateString fieldString w 0>.
  703.      
  704.      super failCheck: chk with: (chk ~= 0) for: 'ascii:toField:width:'.
  705.      
  706.      ^ fieldString
  707. |
  708.    field: aFieldString toASCII: dateString width: w ! chk ! " dBfldtoa() "
  709.      chk <- <primitive 209 9 5 aFieldString w dateString>.
  710.      
  711.      super failCheck: chk with: (chk ~= 0) for: 'field:toASCII:width:'.
  712.  
  713.      ^ dateString
  714. |
  715.    create: fieldName
  716.      ^ self create: fieldName type: $D width: 8 decimalPlaces: 0
  717. |
  718.    create: fieldName type: typeChar width: w decimalPlaces: d ! chk !
  719.  
  720.      " The fieldName can only be up to 10 characters
  721.      * long! (DB-III limitation)
  722.      *
  723.      * Valid values for typeChar are (Uppercase is preferred):
  724.      *
  725.      *   $D - Date field
  726.      "
  727.      chk <- <primitive 209 9 0 fieldName typeChar w d>. 
  728.      
  729.      (chk isNil)
  730.         ifTrue:  [ ('create:type:width:decimalPlaces: FAILED!' ) print.
  731.  
  732.                    ^ nil
  733.                  ].
  734.         
  735.      private       <- chk.
  736.      myFieldName   <- fieldName.
  737.      myFieldType   <- typeChar.
  738.      myFieldWidth  <- w.
  739.      myDecPlaces   <- d.
  740.      
  741.      ^ self
  742. ]
  743.  
  744. " -------------------------------------------------------------------------- "
  745. " This Class is only needed for creating new DataBase DBRecordTemplate       "
  746. " Integer-type Fields.                                                       "
  747. " -------------------------------------------------------------------------- "
  748.  
  749. Class DBFieldInteger :DBField 
  750. ! private myFieldName myFieldType myFieldWidth myDecPlaces !
  751. [
  752.    fieldObject
  753.      ^ private
  754. |
  755.    fieldName
  756.      ^ myFieldName
  757. |
  758.    fieldType
  759.      ^ myFieldType
  760. |
  761.    fieldWidth
  762.      ^ myFieldWidth
  763. |
  764.    decimalPlaces
  765.      ^ myDecPlaces
  766. |
  767.    ascii: anIntegerString toField: fieldString width: w " dBatofld() "
  768.      ! chk !
  769.      
  770.      chk <- <primitive 209 9 4 anIntegerString fieldString w 0>.
  771.      
  772.      super failCheck: chk with: (chk ~= 0) for: 'ascii:toField:width:'.
  773.      
  774.      ^ fieldString
  775. |
  776.    field: aFieldString toASCII: integerString width: w ! chk ! " dBfldtoa() "
  777.      chk <- <primitive 209 9 5 aFieldString w integerString>.
  778.      
  779.      super failCheck: chk with: (chk ~= 0) for: 'field:toASCII:width:'.
  780.  
  781.      ^ integerString
  782. |
  783.    create: fieldName width: w
  784.      ^ self create: fieldName type: $N width: w decimalPlaces: 0
  785. |
  786.    create: fieldName type: typeChar width: w decimalPlaces: d ! chk !
  787.  
  788.      " The fieldName can only be up to 10 characters 
  789.      * long! (DB-III limitation)
  790.      *
  791.      * Valid values for typeChar are (Uppercase is preferred):
  792.      *
  793.      *   $N - Numeric field
  794.      "
  795.      chk <- <primitive 209 9 0 fieldName typeChar w d>. 
  796.      
  797.      (chk isNil)
  798.         ifTrue:  [ ('create:type:width:decimalPlaces: FAILED!' ) print.
  799.  
  800.                    ^ nil
  801.                  ].
  802.         
  803.      private       <- chk.
  804.      myFieldName   <- fieldName.
  805.      myFieldType   <- typeChar.
  806.      myFieldWidth  <- w.
  807.      myDecPlaces   <- d.
  808.      
  809.      ^ self
  810. ]
  811.  
  812. " -------------------------------------------------------------------------- "
  813. " This Class is only needed for creating new DataBase DBRecordTemplate       "
  814. " Boolean-type Fields.                                                       "
  815. " -------------------------------------------------------------------------- "
  816.  
  817. Class DBFieldBoolean :DBField 
  818. ! private myFieldName private2 private3 private4 !
  819. [
  820.    fieldObject
  821.      ^ private
  822. |
  823.    fieldName
  824.      ^ myFieldName
  825. |
  826.    fieldType
  827.      ^ private2
  828. |
  829.    fieldWidth
  830.      ^ private3
  831. |
  832.    decimalPlaces
  833.      ^ private4
  834. |
  835.    create: fieldName
  836.      ^ self create: fieldName type: $L width: 1 decimalPlaces: 0
  837. |
  838.    create: fieldName type: typeChar width: w decimalPlaces: d ! chk !
  839.  
  840.      " The fieldName can only be up to 10 characters 
  841.      * long! (DB-III limitation) 
  842.      "
  843.      chk <- <primitive 209 9 0 fieldName typeChar w d>. 
  844.      
  845.      (chk isNil)
  846.         ifTrue:  [ ('create:type:width:decimalPlaces: FAILED!' ) print.
  847.  
  848.                    ^ nil
  849.                  ].
  850.         
  851.      private     <- chk.
  852.      myFieldName <- fieldName.
  853.      private2    <- typeChar.
  854.      private3    <- w.
  855.      private4    <- d.
  856.      
  857.      ^ self
  858. ]
  859.  
  860. " ------------------------------------------------------------------ "
  861. " This Class is only used to store temporary Objects for DataBases.  "
  862. " ------------------------------------------------------------------ "
  863.  
  864. Class FieldString :String ! private ! 
  865. [
  866.    new: aString
  867.      ^ self xxxFormat: aString to: (aString size) adjMode: $L
  868. |
  869.    size
  870.      ^ (self value) size
  871. |     
  872.    value
  873.      ^ <primitive 209 9 8 private>
  874. |   
  875.    xxxFormat: aString to: length adjMode: leftOrRightChar 
  876.       ! chk ! " dBstrcpy() "
  877.  
  878.       " If leftOrRightChar is $r or $R, right-adjust aString,
  879.       * any other value is for left-adjust.
  880.       "
  881.       chk <- <primitive 209 9 1 aString leftOrRightChar length>.
  882.       
  883.       (chk isNil)
  884.         ifTrue:  [ ('xxxFormat:to:adjMode: FAILED!' ) print.
  885.  
  886.                    ^ nil
  887.                  ].
  888.       
  889.       private <- chk.
  890.  
  891.       ^ self
  892. |
  893.    dispose ! chk !
  894.       <primitive 209 9 2 private>.
  895.  
  896.       chk <- <primitive 209 9 3>. "lastErrorNumber"
  897.  
  898.       (chk ~= 0)
  899.          ifTrue: [ ('Look up ERROR number ', (chk asString)) print ].
  900.          
  901.       ^ private <- nil
  902. ]
  903.  
  904. " ----------------------------------------------------------------- "
  905. " This Class handles most of the interface to DBaseIII index (key)  "
  906. " files.  There are some more methods in the DataBase Class that    "
  907. " also require DBKeyFile Objects                                    "
  908. " ----------------------------------------------------------------- "
  909.  
  910. Class DBKeyFile :Object ! private myFileName !
  911. [
  912.    printError: errNum ! dbErrs !
  913.      dbErrs <- DBErrs new.
  914.  
  915.      (dbErrs errString: errNum) print.
  916.      
  917.      ^ nil
  918. |
  919.    failCheck: check with: failTest for: methodName
  920.      (failTest)
  921.        ifTrue: [ (methodName, ' method FAILED because:') print.
  922.  
  923.                  ^ self printError: check ].
  924.  
  925.      ^ nil
  926. |
  927.    keyFileObject
  928.      ^ private
  929. |
  930.    keyToRecordNumber: thisKey ! chk !    " dBtkey() "
  931.    
  932.      chk <- <primitive 209 8 4 private thisKey>.
  933.      
  934.      (chk isNil) 
  935.        ifTrue:  [ (thisKey, ' FAILED to translate!' ) print ].
  936.  
  937.      ^ chk " This is the recordNumber translated from thisKey "
  938. |
  939.    readKeyExpressionInto: keyExprString ! chk ! " dBkexpr() "
  940.  
  941.      " Returns a keyType value (67 for Character, 78 for Numeric or Date)
  942.      * or nil on failure.  keyString will contain a sequence
  943.      * of characters that describe the logical value (in fields) of the 
  944.      * key expression found in the keyFile.
  945.      "
  946.      chk <- <primitive 209 8 16 private keyExprString>.
  947.      
  948.      self failCheck: chk with: (chk isNil) for: 'readKeyExpressionInto:'.
  949.      
  950.      ^ keyExprString
  951. |
  952.    windKeyFile ! chk !                         " dBfwd()  "
  953.      chk <- <primitive 209 8 10 private>.
  954.      
  955.      self failCheck: chk with: (chk ~= 0) for: 'windKeyFile'.
  956. |
  957.    rewindKeyFile ! chk !                       " dBrewind() "
  958.      chk <- <primitive 209 8 18 private>.
  959.    
  960.      self failCheck: chk with: (chk ~= 0) for: 'rewindKeyFile'.
  961. |
  962.    removeKey: keyString for: recNumber ! chk !               " dBrmvkey() "
  963.      chk <- <primitive 209 8 9 private keyString recNumber>.
  964.      
  965.      self failCheck: chk with: (chk ~= 0) for: 'removeKey:for:'.
  966.      
  967.      (chk = 0)
  968.         ifTrue: [ recNumber <- 0 ]
  969. |
  970.    readCurrentKeyInto: keyString for: recNumber ! chk ! " dBckey() "
  971.      chk <- <primitive 209 8 17 private keyString recNumber>.
  972.  
  973.      self failCheck: chk with: (chk ~= 0) for: 'readCurrentKeyInto:for:'.
  974.      
  975.      ^ recNumber
  976. |
  977.    readNextKeyInto: keyString for: recNumber ! chk ! " dBnkey() "
  978.      chk <- <primitive 209 8 8 private keyString recNumber>.
  979.  
  980.      self failCheck: chk with: (chk ~= 0) for: 'readNextKeyInto:'.
  981.      
  982.      ^ recNumber
  983. |
  984.    readPrevKeyInto: keyString for: recNumber ! chk ! " dBpkey() "
  985.  
  986.      chk <- <primitive 209 8 7 private keyString recNumber>.
  987.  
  988.      self failCheck: chk with: (chk ~= 0) for: 'readPrevKeyInto:'.
  989. |
  990.    cleanup ! chk !
  991.    
  992.      " NOTE:  This is a time-consuming operation! "
  993.  
  994.      chk <- <primitive 209 8 3 private>. " dBiflsh()  "
  995.      
  996.      self failCheck: chk with: (chk ~= 0) for: 'flushFile'.
  997. |
  998.    close ! chk ! " dBiclose() "
  999.  
  1000.      " TESTED & WORKING! "
  1001.  
  1002.      chk <- <primitive 209 8 2 private>.
  1003.      
  1004.      self failCheck: chk with: (chk ~= 0) for: 'closeKeyFile'.
  1005. |
  1006.    open: dbKeyFileName  ! chk !  " dBiopen() "
  1007.  
  1008.      " TESTED & WORKING! "
  1009.  
  1010.      myFileName <- (dbKeyFileName, '.NDX').
  1011.  
  1012.      chk <- <primitive 209 8 1 dbKeyFileName>.
  1013.  
  1014.      (chk isNil) 
  1015.        ifTrue: [ (dbKeyFileName, ' FAILED to open!' ) print.
  1016.  
  1017.                  ^ nil
  1018.                ].
  1019.  
  1020.      private <- chk.
  1021.      
  1022.      ^ self
  1023. |
  1024.    createKeyFile: dbKeyFileName for: keyObject 
  1025.      ! chk keyExpr type ! " dBicreat() "
  1026.  
  1027.      " keyObject has to be a subclass of DBKey " 
  1028.  
  1029.      myFileName <- (dbKeyFileName, '.NDX').
  1030.  
  1031.      keyExpr <- keyObject keyExpression.
  1032.      type    <- keyObject keyType.
  1033.      
  1034.      " keyExpr MUST be less than 100 characters long!
  1035.      *
  1036.      * Valid values for type are:
  1037.      *
  1038.      *   $C -- key is a String
  1039.      *   $N -- key is a Number
  1040.      *   $D -- key is a Date
  1041.      "
  1042.      chk <- <primitive 209 8 0 dbKeyFileName keyExpr type>.
  1043.      
  1044.      self failCheck: chk with: (chk ~= 0) for: 'createKeyFile:for:'.
  1045. ]
  1046.  
  1047. " ------------------------------------------------------------------- "
  1048. " DBKey Class is an Abstract class for the different types of keys    "
  1049. " known to the DBC-III library of functions.                          "
  1050. " ------------------------------------------------------------------- "
  1051.  
  1052. Class DBKey :Object
  1053. [
  1054.    printError: errNum ! dbErrs !
  1055.      dbErrs <- DBErrs new.
  1056.  
  1057.      (dbErrs errString: errNum) print.
  1058.      
  1059.      ^ nil
  1060. |
  1061.    failCheck: check with: failTest for: methodName
  1062.      (failTest)
  1063.        ifTrue: [ (methodName, ' method FAILED because:') print.
  1064.  
  1065.                  ^ self printError: check ].
  1066.  
  1067.      ^ nil
  1068. |
  1069.    keyExpression
  1070.      ^ super subclassResponsibility: 'keyExpression'
  1071. |
  1072.    keyExpression: newKeyExpression
  1073.      ^ super subclassResponsibility: 'keyExpression:'
  1074. |
  1075.    keyType
  1076.      ^ super subclassResponsibility: 'keyType'
  1077. |
  1078.    keyLength
  1079.      ^ super subclassResponsibility: 'keyLength'
  1080. |
  1081.    keyToASCII: aKeyValue
  1082.      ^ super subclassResponsibility: 'keyToASCII:'
  1083. |
  1084.    asciiToKey: aStringValue
  1085.      ^ super subclassResponsibility: 'asciiToKey:'
  1086. |   
  1087.    value
  1088.      ^ super subclassResponsibility: 'value'
  1089. |
  1090.    new: newKeyType
  1091.  
  1092.      ^ super subclassResponsibility: 'new:'
  1093. ]
  1094.  
  1095. " --------------------------------------------------------------------- "
  1096. " This Class is for date-type keys only.                                "
  1097. " --------------------------------------------------------------------- "
  1098.  
  1099. Class DBDateKey :DBKey ! myKeyValue myKeyExpr myKeyLength !
  1100. [
  1101.    keyExpression
  1102.      ^ myKeyExpr
  1103. |
  1104.    keyExpression: newKeyExpression
  1105.      myKeyExpr <- newKeyExpression
  1106. |
  1107.    keyType
  1108.      ^ 68      " key Type is date = $D "
  1109. |
  1110.    keyLength
  1111.      ^ myKeyLength
  1112. |
  1113.    keyToASCII: dateString ! chk ! " dBkeytoa() "
  1114.  
  1115.      " Receiver HAS to be 8 bytes in size. "
  1116.  
  1117.      chk <- <primitive 209 8 13 dateString myKeyValue 68>.
  1118.      
  1119.      super failCheck: chk with: (chk ~= 0) for: 'keyToASCII:'.
  1120.      
  1121.      ^ dateString
  1122. |
  1123.    asciiToKey: dateString ! chk ! " dBatokey() "
  1124.  
  1125.      " Receiver HAS to be 8 bytes in size. "
  1126.  
  1127.      chk <- <primitive 209 8 12 dateString myKeyValue 68>.
  1128.      
  1129.      super failCheck: chk with: (chk ~= 0) for: 'asciiToKey:'.
  1130.      
  1131.      ^ myKeyValue
  1132. |
  1133.    value
  1134.      ^ myKeyValue
  1135. |
  1136.    new: newKeyType
  1137.  
  1138.      myKeyValue  <- String new: 8. 
  1139.      " FORMAT is 19YYMMDD for DBaseIII compatibility.
  1140.      * If DBaseIII compatibility is not needed, put the 
  1141.      * correct date inside (such as 20YYMMDD). 
  1142.      "
  1143.  
  1144.      myKeyLength <- 8.
  1145.      myKeyExpr   <- nil.
  1146.      
  1147.      ^ self
  1148. ]
  1149.  
  1150. " --------------------------------------------------------------------- "
  1151. " This Class is for numeric keys, integers only.                        "
  1152. " --------------------------------------------------------------------- "
  1153.  
  1154. Class DBIntegerKey :Object ! myKeyValue myKeyExpr myKeyLength !
  1155. [
  1156.    keyExpression
  1157.      ^ myKeyExpr
  1158. |
  1159.    keyExpression: newKeyExpression
  1160.      myKeyExpr <- newKeyExpression
  1161. |
  1162.    keyType
  1163.      ^ 78      " key Type is numeric = $N "
  1164. |
  1165.    keyLength
  1166.      ^ myKeyLength
  1167. |
  1168.    keyToASCII: numberString ! chk ! " dBkeytoa() "
  1169.  
  1170.      " Receiver HAS to be 8 bytes in size.  The first byte in 
  1171.      * numberString is the number of decimal places (0 to 60) in the converted
  1172.      * numberString, which is only meaningful for this Class.
  1173.      *
  1174.      * numberString can be up to 64 characters long, so make sure that
  1175.      * you create a String that is sized this large!
  1176.      *
  1177.      *   EXAMPLE:  nString <- String new: 64.
  1178.      *             nString at: 1 put: (numDecimalPlaces asCharacter).
  1179.      *             dbIndex keyToASCII: nString
  1180.      "
  1181.      chk <- <primitive 209 8 13 numberString myKeyValue 78>.
  1182.      
  1183.      super failCheck: chk with: (chk ~= 0) for: 'keyToASCII:'.
  1184.      
  1185.      ^ numberString
  1186. |
  1187.    asciiToKey: numberString ! chk ! " dBatokey() "
  1188.  
  1189.      " Receiver HAS to be 8 bytes in size.  "
  1190.  
  1191.      chk <- <primitive 209 8 12 numberString myKeyValue 78>.
  1192.      
  1193.      super failCheck: chk with: (chk ~= 0) for: 'asciiToKey:'.
  1194.      
  1195.      ^ myKeyValue
  1196. |
  1197.    value
  1198.      ^ myKeyValue
  1199. |
  1200.    new: newKeyType
  1201.  
  1202.      myKeyValue  <- String new: 8.
  1203.      myKeyLength <- 8.
  1204.      myKeyExpr   <- nil.
  1205.      
  1206.      ^ self
  1207. ]
  1208.  
  1209. " -------------------------------------------------------------------- "
  1210. " This Class is for keys that are characters in nature, as opposed to  "
  1211. " numeric.                                                             "
  1212. " -------------------------------------------------------------------- "
  1213.  
  1214. Class DBCharKey :DBKey ! myKeyValue myKeyExpr myKeyLength !
  1215. [
  1216.    keyExpression
  1217.      ^ myKeyExpr
  1218. |
  1219.    keyExpression: newKeyExpression
  1220.      myKeyExpr <- newKeyExpression
  1221. |
  1222.    keyType
  1223.      ^ 67      " key Type is character = $C "
  1224. |
  1225.    keyLength
  1226.      ^ myKeyLength
  1227. |
  1228.    keyToASCII: aString ! chk ! " dBkeytoa() "
  1229.  
  1230.      " Receiver HAS to be 8 bytes in size.
  1231.      *
  1232.      * aString can be up to 64 characters long, so make sure that
  1233.      * you create a String that is sized this large!
  1234.      *
  1235.      *   EXAMPLE:  nString <- String new: 64.
  1236.      *             dbIndex keyToASCII: aString
  1237.      "
  1238.      chk <- <primitive 209 8 13 aString myKeyValue 67>.
  1239.      
  1240.      super failCheck: chk with: (chk ~= 0) for: 'keyToASCII:'.
  1241.      
  1242.      ^ aString
  1243. |
  1244.    asciiToKey: aString ! chk ! " dBatokey() "
  1245.  
  1246.      " Receiver HAS to be 8 bytes in size.  "
  1247.  
  1248.      chk <- <primitive 209 8 12 aString myKeyValue 67>.
  1249.      
  1250.      super failCheck: chk with: (chk ~= 0) for: 'asciiToKey:'.
  1251.      
  1252.      ^ myKeyValue
  1253. |
  1254.    value
  1255.      ^ myKeyValue
  1256. |
  1257.    new: newKeyType
  1258.  
  1259.      myKeyValue  <- String new: 8.
  1260.      myKeyLength <- 8.
  1261.      myKeyExpr   <- nil.
  1262.      
  1263.      ^ self
  1264. ]
  1265.  
  1266. " -------------------------------------------------------------------- "
  1267. " DBErrs Class is a Singleton class that allows the user to            "
  1268. " reference DBase error strings by error number, effectivley trans-    "
  1269. " an error number into something (potentially) understandable by a     "
  1270. " Human.  The other DataBase Classes contained in this file will       "
  1271. " instantiate this Class when necessary, so ignore it.                 "
  1272. ""
  1273. "  EXAMPLE:  'errStr <- dbErrs errString: 102.                         "
  1274. ""
  1275. " ALL singleton classes MUST contain the following:                    "
  1276. ""
  1277. "   the methods:  isSingleton AND privateSetup     AND                 "
  1278. "                 uniqueInstance Class instance variable.              "
  1279. " -------------------------------------------------------------------- "
  1280.  
  1281. Class DBErrs :Dictionary ! uniqueInstance !
  1282. [
  1283.    isSingleton
  1284.      ^ true
  1285. |
  1286.    privateNew ! newinstance !
  1287.      newinstance <- super new.
  1288.  
  1289.      ^ newinstance
  1290. |
  1291.    new
  1292.      ^ self privateSetup
  1293. |
  1294.    privateSetup
  1295.      (uniqueInstance isNil)
  1296.        ifTrue: [uniqueInstance <- self privateNew.
  1297.  
  1298.                 self privateInitializeDictionary.
  1299.                ].
  1300.                
  1301.      ^ self    "or ^ uniqueInstance??"
  1302. |
  1303.    errString: aKey
  1304.      ^ self at: aKey
  1305. |
  1306.    privateInitializeDictionary
  1307.  
  1308.      self at: 101  put: 'Number of Fields is 0 (zero).'.
  1309.      self at: 102  put: 'Number of Fields is > 128.'.
  1310.      self at: 103  put: 'Field Name > 10 characters.'.
  1311.      self at: 104  put: 'Invalid Field type specified.'.
  1312.      self at: 105  put: 'Field length is 0 or > 254 bytes.'.
  1313.      self at: 106  put: 'Record length is > 4000 bytes.'. 
  1314.      self at: 107  put: 'Failed to create .DBF file at physical level.'.
  1315.      self at: 108  put: 'Failed to write to .DBF file at physical level.'.
  1316.      self at: 114  put: 'Dynamic Memory Allocation Failure!'.
  1317.      self at: 115  put: 'Environment NOT initialized!'.
  1318.      self at: 116  put: 'Variable NOT big enough!'.
  1319.  
  1320.      self at: 201  put: 'Maximum number of .DBF files already open.'.
  1321.      self at: 202  put: '.DBF file open failure at physical level.'.
  1322.      self at: 203  put: 'Failed to read .DBF file at physical level.'.
  1323.      self at: 204  put: 'File not recognized as a .DBF file.'.
  1324.      self at: 205  put: 'File cannot be recognized as a .DBF file.'.
  1325.  
  1326.      self at: 301  put: 'Failed to seek the .DBF file at physical level.'.
  1327.      self at: 302  put: 'Failed to write onto the .DBF file at physical level.'.
  1328.      self at: 303  put: 'Failed to close the .DBF file at physical level.'.
  1329.      self at: 390  put: 'The .DBF file is NOT open!'.
  1330.  
  1331.      self at: 401  put: 'Record number too big or zero.'.
  1332.      self at: 402  put: 'Failed to seek the .DBF file at physical level.'.
  1333.      self at: 403  put: 'Failed to read the .DBF file at physical level.'.
  1334.  
  1335.      self at: 501  put: 'Record number too big or zero.'.
  1336.  
  1337.      self at: 601  put: 'Record number too big or zero.'.
  1338.  
  1339.      self at: 701  put: 'Record number too big or zero.'.
  1340.      self at: 702  put: 'Failed to seek or read the .DBF file at physical level.'.
  1341.      self at: 703  put: 'Failed to seek or read the .DBF file at physical level.'.
  1342.      self at: 704  put: 'Failed to seek or read the .DBF file at physical level.'.
  1343.      self at: 705  put: 'Static data corrupted possibly by application overwrite.'.
  1344.  
  1345.      self at: 1001 put: 'Static data corrupted possibly by application overwrite.'.
  1346.  
  1347.      self at: 1201 put: 'Failed to seek the .DBF file at physical level.'.
  1348.      self at: 1202 put: 'Failed to seek the .DBF file at physical level.'.
  1349.      self at: 1203 put: 'Failed to seek the .DBF file at physical level.'.
  1350.      self at: 1204 put: 'Failed to seek the .DBF file at physical level.'.
  1351.      self at: 1205 put: 'Static data corrupted possibly by application overwrite.'.
  1352.      self at: 1206 put: 'Failed to write the .DBF file at physical level.'.
  1353.      self at: 1210 put: 'Failed to allocate dynamic memory for shift-down operation.'.
  1354.      self at: 1211 put: 'Failed to read the .DBF file for shift-down operation.'.
  1355.      self at: 1212 put: 'Failed to seek the .DBF file for shift-down operation.'.
  1356.      self at: 1213 put: 'Failed to write the .DBF file for shift-down operation.'.
  1357.      self at: 1214 put: 'Failed to seek the .DBF file for shift-down operation.'.
  1358.      self at: 1215 put: 'Failed to seek the .DBF file for shift-down operation.'.
  1359.      self at: 1216 put: 'Failed to seek the .DBF file after shift-down operation.'.
  1360.      self at: 1220 put: 'Failed to allocate dynamic memory for shift-up operation.'.
  1361.      self at: 1221 put: 'Failed to seek the .DBF file for shift-up operation.'.
  1362.      self at: 1222 put: 'Failed to read the .DBF file for shift-up operation.'.
  1363.      self at: 1223 put: 'Failed to seek the .DBF file for shift-up operation.'.
  1364.      self at: 1224 put: 'Failed to write the .DBF file for shift-up operation.'.
  1365.      self at: 1225 put: 'Failed to seek the .DBF file for shift-up operation.'.
  1366.      self at: 1226 put: 'Failed to seek the .DBF file after shift-up operation.'.
  1367.  
  1368.      self at: 1301 put: 'Undefined "keytype" specified.'.
  1369.      self at: 1302 put: 'Key length too long or zero.'.
  1370.      self at: 1303 put: 'Failed to allocate dynamic memory.'.
  1371.      self at: 1304 put: 'Key expression too long or zero.'.
  1372.      self at: 1305 put: 'Failed to create the .NDX file at physical level.'.
  1373.      self at: 1306 put: 'Failed to write the .NDX file at physical level.'.
  1374.  
  1375.      self at: 1401 put: 'Maximum # of .NDX files already open!'.
  1376.      self at: 1402 put: 'Failed to open the .NDX file at physical level.'.
  1377.      self at: 1403 put: 'Failed to allocate dynamic memory.'.
  1378.      self at: 1404 put: 'Failed to read the .NDX file at physical level.'.
  1379.      self at: 1405 put: 'File cannot be recognized as a .NDX file!'.
  1380.  
  1381.      self at: 1501 put: 'No longer used as error code.'.
  1382.      self at: 1502 put: 'No longer used as error code.'.
  1383.      self at: 1503 put: 'Failed to seek or write the .NDX file at physical level.'.
  1384.      self at: 1504 put: 'Failed to close the .NDX file at physical level.'.
  1385.      self at: 1590 put: 'The .NDX file is NOT open!'.
  1386.  
  1387.      self at: 1601 put: 'Failed to allocate dynamic memory.'.
  1388.      self at: 1602 put: 'Failed to allocate dynamic memory.'.
  1389.      self at: 1603 put: 'Failed to allocate dynamic memory.'.
  1390.      self at: 1604 put: 'Failed to allocate dynamic memory.'.
  1391.      self at: 1605 put: 'Failed to seek the .NDX file at physical level.'.
  1392.      self at: 1606 put: 'Failed to write the .NDX file at physical level.'.
  1393.      self at: 1607 put: 'Failed to seek the .NDX file at physical level.'.
  1394.      self at: 1608 put: 'Failed to write the .NDX file at physical level.'.
  1395.      self at: 1609 put: 'Failed to allocate dynamic memory.'.
  1396.  
  1397.      self at: 1701 put: 'Requested key NOT found! (New .NDX file?)'.
  1398.      self at: 1702 put: 'Requested key NOT found in the .NDX file.'.
  1399.      self at: 1703 put: 'The .NDX file corrupted.'.
  1400.      self at: 1710 put: 'Failed to allocate dynamic memory.'.
  1401.  
  1402.      self at: 1810 put: 'Top of the .NDX file reached.'.
  1403.      self at: 1820 put: 'No keys found in .NDX file!'.
  1404.  
  1405.      self at: 1901 put: 'No current key positioned.'.
  1406.      self at: 1902 put: 'End of the .NDX file reached.'.
  1407.  
  1408.      self at: 2010 put: 'End of the .NDX file reached.'.
  1409.      self at: 2020 put: 'No keys found in .NDX file!'.
  1410.  
  1411.      self at: 2101 put: 'The .DBF file is NOT open!'.
  1412.      self at: 2102 put: 'The .NDX file is NOT open!'.
  1413.  
  1414.      self at: 2201 put: 'The .DBF file is NOT open!'.
  1415.      self at: 2202 put: 'The .NDX file is NOT open!'.
  1416.  
  1417.      self at: 2301 put: 'The .DBF file is NOT open!'.
  1418.      self at: 2302 put: 'The .NDX file is NOT open!'.
  1419.  
  1420.      self at: 2401 put: 'The .DBF file is NOT open!'.
  1421.      self at: 2402 put: 'The .NDX file is NOT open!'.
  1422.      self at: 2403 put: 'The .DBF & .NDX out of sync!'.
  1423.  
  1424.      self at: 2501 put: 'Failed to seek the .NDX file at physical level.'.
  1425.      self at: 2502 put: 'Failed to allocate dynamic memory.'.
  1426.      self at: 2503 put: 'Failed to read the .NDX file at physical level.'.
  1427.      self at: 2504 put: 'Key expression in .NDX file TOO LONG!'.
  1428.  
  1429.      self at: 2601 put: 'No key exists in the .NDX file.'.
  1430.      self at: 2602 put: 'Synonymous to MAYBE.'.
  1431.      self at: 2603 put: 'End of the .NDX file reached (Key is past the end!).'.
  1432.  
  1433.      self at: 2701 put: 'Failed to seek the .NDX file at physical level.'.
  1434.      self at: 2702 put: 'Failed to read the .NDX file at physical level.'.
  1435.      self at: 2703 put: 'Failed to allocate dynamic memory.'.
  1436.      self at: 2704 put: 'Failed to seek the .NDX file at physical level.'.
  1437.      self at: 2705 put: 'Failed to read the .NDX file at physical level.'.
  1438.  
  1439.      self at: 2801 put: 'Failed to seek the .NDX file at physical level.'.
  1440.      self at: 2802 put: 'Failed to seek or write the .NDX file at physical level.'.
  1441.  
  1442.      self at: 3301 put: 'Failed to allocate dynamic memory.'.
  1443.  
  1444.      self at: 3401 put: 'Failed to allocate dynamic memory.'.
  1445.  
  1446.      self at: 4001 put: 'Failed to create the .DBT file at physical level.'.
  1447.      self at: 4002 put: 'Failed to write the .DBT file at physical level.'.
  1448.  
  1449.      self at: 4101 put: 'Maximum # of .DBT files already open!'.
  1450.      self at: 4102 put: 'Failed to open the .DBT file at physical level.'.
  1451.      self at: 4103 put: 'Failed to read the .DBT file at physical level.'.
  1452.  
  1453.      self at: 4201 put: 'Failed to seek or write the .DBT file at physical level.'.
  1454.      self at: 4202 put: 'Failed to close the .DBT file at physical level.'.
  1455.      self at: 4290 put: 'The .DBT file is NOT open!'.
  1456.  
  1457.      self at: 4301 put: 'Memo field contents invalid.'.
  1458.      self at: 4302 put: 'Failed to seek the .DBT file at physical level.'.
  1459.      self at: 4303 put: 'Failed to allocate dynamic memory.'.
  1460.      self at: 4304 put: 'Failed to read the .DBT file at physical level.'.
  1461.      self at: 4305 put: '_dbcmsig value too small, .DBT file corrupted!'.
  1462.  
  1463.      self at: 4401 put: 'Failed to seek the .DBT file at physical level.'.
  1464.      self at: 4402 put: 'Failed to seek the .DBT file at physical level.'.
  1465.      self at: 4403 put: 'The .DBT file is corrupted!'.
  1466.      self at: 4404 put: 'Failed to allocate dynamic memory.'.
  1467.      self at: 4405 put: 'Failed to write the .DBT file at physical level.'.
  1468.      self at: 4406 put: 'Failed to allocate dynamic memory.'.
  1469.      self at: 4407 put: 'Failed to write the .DBT file at physical level.'.
  1470.  
  1471.      " My Additions to the error report strings: "
  1472.  
  1473.      self at: 4408 put: 'Attempt to free a NULL Pointer!'. 
  1474.      self at: 4409 put: 'Data was NULL (or nil).'.
  1475.      self at: 4410 put: 'Could NOT re-open file after updating # of records!'.
  1476.      self at: 4411 put: 'Could NOT close file to update # of records!'. 
  1477. ]
  1478.